/*******************************************************************************
 * Copyright (c) 2010 NineConsult A/S (http://nine.dk) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package dk.nineconsult.jmoller.mapr.formatting;

import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
import org.eclipse.xtext.formatting.impl.FormattingConfig;

/**
 * This class contains custom formatting description.
 * 
 * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting
 * on how and when to use it 
 * 
 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
 */
public class MaprFormatter extends AbstractDeclarativeFormatter {
	
	@Override
	protected void configureFormatting(FormattingConfig c) {
		dk.nineconsult.jmoller.mapr.services.MaprGrammarAccess f = (dk.nineconsult.jmoller.mapr.services.MaprGrammarAccess) getGrammarAccess();

		c.setLinewrap(0, 1, 2).before(f.getSL_COMMENTRule());
		c.setLinewrap(0, 1, 2).before(f.getML_COMMENTRule());
		c.setLinewrap(0, 1, 1).after(f.getML_COMMENTRule());

		c.setIndentation(f.getMappingAccess().getLeftCurlyBracketKeyword_7(), f.getMappingAccess().getRightCurlyBracketKeyword_9());
		c.setLinewrap(0,1,2).after(f.getMappingRule());

		c.setLinewrap(1,1,1).before(f.getFeatureMapRule());
		c.setLinewrap(1,1,2).after(f.getFeatureMapRule());

		c.setLinewrap(1,1,2).before(f.getMappingAccess().getBetweenKeyword_3());
		c.setLinewrap(1,1,2).before(f.getMappingAccess().getAndKeyword_5());

		c.setNoSpace().around(f.getFeatureMapAccess().getFullStopKeyword_1_1());
		c.setNoSpace().around(f.getFeatureMapAccess().getFullStopKeyword_2_1());
		c.setNoSpace().around(f.getFeatureMapAccess().getFullStopKeyword_3_3());
		c.setNoSpace().around(f.getFeatureMapAccess().getFullStopKeyword_4_3());
		c.setNoSpace().around(f.getFeatureMapAccess().getFullStopKeyword_5_2());
		c.setNoSpace().around(f.getFeatureMapAccess().getFullStopKeyword_6_2());
	}
}
